package com.pond.pond.domain;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.pond.common.core.annotation.Excel;
import com.pond.common.core.web.domain.BaseEntity;

import java.util.Date;

/**
 * App版本信息对象 app_versions
 */
public class AppVersion extends BaseEntity {
    private static final long serialVersionUID = 1L;

    /** 主键ID */
    private Long id;

    /** 版本号，格式：YYYY.MM.DD.HHmm */
    @Excel(name = "版本号")
    private String versionCode;

    /** 版本名称，如：v1.2.0 */
    @Excel(name = "版本名称")
    private String versionName;

    /** 构建号，递增 */
    @Excel(name = "构建号")
    private Integer buildNumber;

    /** APK文件名 */
    @Excel(name = "文件名")
    private String fileName;

    /** 文件大小（字节） */
    @Excel(name = "文件大小")
    private Long fileSize;

    /** 文件MD5校验值 */
    @Excel(name = "MD5校验值")
    private String fileMd5;

    /** 下载链接 */
    @Excel(name = "下载链接")
    private String downloadUrl;

    /** 更新说明 */
    @Excel(name = "更新说明")
    private String updateDescription;

    /** 最低支持版本 */
    @Excel(name = "最低支持版本")
    private String minSupportedVersion;

    /** 是否启用 */
    @Excel(name = "是否启用")
    private Boolean isActive;

    /** 是否为最新版本 */
    @Excel(name = "是否最新版本")
    private Boolean isLatest;

    /** 创建时间 */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createdAt;

    /** 更新时间 */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date updatedAt;

    public void setId(Long id) {
        this.id = id;
    }

    public Long getId() {
        return id;
    }

    public void setVersionCode(String versionCode) {
        this.versionCode = versionCode;
    }

    public String getVersionCode() {
        return versionCode;
    }

    public void setVersionName(String versionName) {
        this.versionName = versionName;
    }

    public String getVersionName() {
        return versionName;
    }

    public void setBuildNumber(Integer buildNumber) {
        this.buildNumber = buildNumber;
    }

    public Integer getBuildNumber() {
        return buildNumber;
    }

    public void setFileName(String fileName) {
        this.fileName = fileName;
    }

    public String getFileName() {
        return fileName;
    }

    public void setFileSize(Long fileSize) {
        this.fileSize = fileSize;
    }

    public Long getFileSize() {
        return fileSize;
    }

    public void setFileMd5(String fileMd5) {
        this.fileMd5 = fileMd5;
    }

    public String getFileMd5() {
        return fileMd5;
    }

    public void setDownloadUrl(String downloadUrl) {
        this.downloadUrl = downloadUrl;
    }

    public String getDownloadUrl() {
        return downloadUrl;
    }

    public void setUpdateDescription(String updateDescription) {
        this.updateDescription = updateDescription;
    }

    public String getUpdateDescription() {
        return updateDescription;
    }

    public void setMinSupportedVersion(String minSupportedVersion) {
        this.minSupportedVersion = minSupportedVersion;
    }

    public String getMinSupportedVersion() {
        return minSupportedVersion;
    }

    public void setIsActive(Boolean isActive) {
        this.isActive = isActive;
    }

    public Boolean getIsActive() {
        return isActive;
    }

    public void setIsLatest(Boolean isLatest) {
        this.isLatest = isLatest;
    }

    public Boolean getIsLatest() {
        return isLatest;
    }

    public void setCreatedAt(Date createdAt) {
        this.createdAt = createdAt;
    }

    public Date getCreatedAt() {
        return createdAt;
    }

    public void setUpdatedAt(Date updatedAt) {
        this.updatedAt = updatedAt;
    }

    public Date getUpdatedAt() {
        return updatedAt;
    }

    /**
     * 获取文件大小（MB格式）
     */
    public String getFileSizeMB() {
        if (fileSize == null) {
            return "0";
        }
        double sizeMB = fileSize / (1024.0 * 1024.0);
        return String.format("%.1f", sizeMB);
    }
}